package com.MyDemo.demo.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
class RedisConfig {

    // @Bean
    // LettuceConnectionFactory connectionFactory() {
    // return new LettuceConnectionFactory();
    // }
    //
    // @Bean
    // RedisTemplate<String, String> redisTemplate(RedisConnectionFactory
    // connectionFactory) {
    //
    // RedisTemplate<String, String> template = new RedisTemplate<>();
    // template.setConnectionFactory(connectionFactory);
    // return template;
    // }

    @Bean
    public RedissonClient createRedissonClient() {
        Config config = new Config();
        config.useSingleServer()
                // use "redis://" for Redis connection
                // use "valkey://" for Valkey connection
                // use "valkeys://" for Valkey SSL connection
                // use "rediss://" for Redis SSL connection
                .setAddress("redis://192.168.150.101:6379")
                .setPassword("123321");

        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}